<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function maxandmin(arr) {
            var max = arr[0];
            var maxindex = 0;
            var min = arr[0];
            var minindex = 0;
            for (var i = 1; i <= arr.length-1; i++) {
                if (arr[i] > max) {
                    max = arr[i];
                    maxindex = i;
                }
                if (arr[i] < min) {
                    min = arr[i];
                    minindex = i;
                }
            }
            return console.log("这组数中最大值是"+ max +"，最大值下标是"+ maxindex +"，最小值是"+ min +"，最小值下标是" + minindex);
        }
        
        maxandmin([12,89,57,9,34,22,33,45]);
        
    </script>
</head>
<body>
    
</body>
</html>